<%@page contentType="text/html;charset=utf-8" %>
<%@taglib prefix="s" uri="/struts-tags" %> 
<script type="text/javascript">
function pi_listdeployed(pid)
{
	if (pid == null || pid == "")
		pid = document.getElementById("plugin.id").value;
	var url = "pi/deploy/list.do";
    var content = "deployed.plugin=" + pid;
    var objectid = "content";
    /*alert(content);*/
    sendXMLHttpRequest(url, content, objectid); 
}

function pi_showdeployed(id)
{
    var pid = document.getElementById("plugin.id").value;
    var url = "pi/deploy/show.do";
    var content = "deployed.id=" + id
                + "&deployed.plugin=" + pid;
    var objectid = "pi_deployed";
    /*alert(content);*/
    sendXMLHttpRequest(url, content, objectid); 
}

function pi_setdeployedonline(id, type)
{
    var url = "pi/deploy/save.do";
    var content = "deployed.id=" + id
                + "&type=" + type;
    var objectid = "deployed_status_" + id;
    sendXMLHttpRequest(url, content, objectid); 
}
</script>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="5"></td>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="5"></td>
      </tr>
      <tr>
        <td height="25" class="t1">
          <img src="images/small0.gif" width="14" height="12"> 您现在的位置&gt;&gt;版本发行</td>
      </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td >
        <table width="100%"  border="0" cellspacing="0" cellppkgding="0">
          <tr>
            <td><img src="images/table_top_left.jpg" width="20" height="15" /></td>
            <td><img src="images/table_top_bg.jpg" width="770" height="15"/></td>
            <td align="right">
              <img src="images/table_top_right.jpg" width="20" height="15" /></td>
          </tr>
        </table>
        </td>
      </tr>
      <tr>
        <td height="25" class="table_blue">
          <input type="hidden" value="<s:property value="merchant.id"/>" id="merchantid" />
          <strong><img src="images/dot.jpg" width="13" height="9">部署列表</strong>&nbsp;&nbsp;
          <select id="plugin.id" name="plugin.id" onchange="pi_listdeployed(this.value);" >
            <s:iterator value="plugins" >
            <option value="<s:property value="id" />" <s:if test="id==deployed.plugin">selected</s:if> ><s:property value="name"/></option>
            </s:iterator>
          </select>
          <span style="float:right;color:#000000;">        
          <button id="btn1" dojoType="dijit.form.Button" 
            onclick="pi_showdeployed(-1);">新增</button>
          &nbsp;&nbsp;
          </span>
          </td>
      </tr>   
      <tr>
      <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="0"
           style="word-break:break-all;">
      <tr>
        <td align="center" class="table_g1" width="5%">序号</td>
        <td align="center" class="table_g2" width="10%">渠道</td>
        <td align="center" class="table_g2" width="10%">项目</td>
        <td align="center" class="table_g2" width="10%">版本</td>
        <td align="center" class="table_g2" width="20%">文件</td>
        <td align="center" class="table_g2" width="10%">CRC</td>
        <td align="center" class="table_g2" width="10%">部署日期</td>
        <td align="center" class="table_g2" width="5%">状态</td>
        <td align="center" class="table_g2" width="10%"></td>
      </tr>
      
      <s:if test="deployeds.size > 0" >
        <s:iterator value="deployeds" status="stat">
        <tr onmouseover="this.style.background='#c0c0c0';" 
            onmouseout="this.style.background='#ffffff';"> 
          <td class="table_w1" align="center"><s:property value="#stat.index+1" /></td>
          <td class="table_w2" align="center"><s:property value="channelName" /></td>
          <td class="table_w2" align="center"><s:property value="projectName" /></td>
          <td class="table_w2" align="center"><s:property value="version" /></td>
          <td class="table_w2" align="center" title="点击下载"><a href="<s:property value="%{getConfig('plugin','download.url')+'/'+deployeds.get(#stat.index).getSavePath()}" />"><s:property value="fileName" /></a></td>
          <td class="table_w2" align="center"><s:property value="fileCrc" /></td>
          <td class="table_w2" align="center"><s:property value="%{formatDate(deployed,'yyyy-MM-dd')}"/></td>
          <td class="table_w2" align="center"><div id="deployed_status_<s:property value="id"/>">
            <a href="javascript:void(0);" title="<s:if test="status==0">点击下线</s:if><s:else>点击上线</s:else>" 
                onclick="pi_setdeployedonline('<s:property value="id"/>', '<s:if test="status==0">offline</s:if><s:else>online</s:else>');"><s:property value="%{getConstantString('plugin status',status)}" /></a></div></td>          
          <td class="table_w2" align="center">
            <a href="javascript:void(0);" 
              onclick="pi_showdeployed(<s:property value="id" />);">修改</a>
        </tr>    
        </s:iterator>
      </s:if>
      <s:else>
      <tr>
        <td class="table_w1" align="center" colspan="9">无</td>
      </tr>
      </s:else>
      </table>
      </td>
      </tr>
      <tr> 
        <td background="images/table_bom_bg.jpg">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>
              <img src="images/table_bom_left.jpg" width="20" height="15"></td>
            <td></td>
            <td align="right">
              <img src="images/table_bom_right.jpg" width="20" height="15"></td>
          </tr>
          </table>
        </td>
      </tr>
    </table>  
  </td>
  <td width="5"></td>
  </tr>
  </table>
  <div id="pi_deployed"></div>  